package com.ruoyi.web.controller.moon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.houbb.sensitive.word.core.SensitiveWordHelper;
import com.ruoyi.common.config.MySensitiveWordReplace;
import com.ruoyi.moon.domain.MoonReviews;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.moon.domain.MoonUpvote;
import com.ruoyi.moon.service.IMoonUpvoteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 赞踩管理Controller
 * 
 * @author admin
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/moon/upvote")
public class MoonUpvoteController extends BaseController
{
    @Autowired
    private IMoonUpvoteService moonUpvoteService;

    /**
     * 查询赞踩管理列表
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoonUpvote moonUpvote)
    {
        startPage();
        List<MoonUpvote> list = moonUpvoteService.selectMoonUpvoteList(moonUpvote);
        return getDataTable(list);
    }

    /**
     * 导出赞踩管理列表
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:export')")
    @Log(title = "赞踩管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MoonUpvote moonUpvote)
    {
        List<MoonUpvote> list = moonUpvoteService.selectMoonUpvoteList(moonUpvote);
        ExcelUtil<MoonUpvote> util = new ExcelUtil<MoonUpvote>(MoonUpvote.class);
        util.exportExcel(response, list, "赞踩管理数据");
    }

    /**
     * 获取赞踩管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(moonUpvoteService.selectMoonUpvoteById(id));
    }

    /**
     * 新增赞踩管理
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:add')")
    @Log(title = "赞踩管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoonUpvote moonUpvote)
    {
        return toAjax(moonUpvoteService.insertMoonUpvote(moonUpvote));
    }

    /**
     * 修改赞踩管理
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:edit')")
    @Log(title = "赞踩管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoonUpvote moonUpvote)
    {
        return toAjax(moonUpvoteService.updateMoonUpvote(moonUpvote));
    }

    /**
     * 删除赞踩管理
     */
    @PreAuthorize("@ss.hasPermi('moon:upvote:remove')")
    @Log(title = "赞踩管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(moonUpvoteService.deleteMoonUpvoteByIds(ids));
    }



}
